package com.xunk.scene.domain;

import com.xunk.common.core.annotation.EnumCheck;
import com.xunk.common.core.annotation.Excel;
import com.xunk.common.core.utils.StringUtils;
import com.xunk.common.core.web.domain.BaseEntity;
import com.xunk.scene.enums.FlagOneZeroEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @ProjectName: HIM
 * @Package: com.xunk.scene.domain
 * @ClassName: Scene
 * @Author: luanzhiwei
 * @Description: 场景表实体类
 * @Date: 2021/5/6 9:46
 * @Version: 1.0
 */
@Data
@ToString
@NoArgsConstructor
@EqualsAndHashCode
public class Scene extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 自增主键
     */
    @NotNull(message = "场景id不能为空", groups = {Update.class})
    private Long id;

    /**
     * 场景名称
     */
    @Excel(name = "场景名称")
    @NotBlank(message = "场景名称不能为空", groups = {Add.class, Update.class, Model.class})
    private String sceneName;

    /**
     * 模板场景的场景编号，用于APP对应展示背景图片
     */
    @NotBlank(message = "场景编码不能为空", groups = {Model.class})
    private String sceneCode;

    /**
     * 首页标识1是0否
     */
    @EnumCheck(enableClass = FlagOneZeroEnum.class, message = "homePage为错误的枚举值", groups = {Add.class, Update.class, Model.class})
    private String homePage;

    /**
     * 场景头像地址
     */
    private String profileUrl;

    /**
     * 家庭id
     */
    @Excel(name = "家庭id")
    @NotNull(message = "homeId不能为空", groups = {Add.class, Update.class})
    private Long homeId;

    /**
     * 删除标识,0正常1删除
     */
    private String delFlag;

    /**
     * 启动标识，0关闭，1启动，用于标识该场景是否可被触发执行，默认开启
     */
    @Excel(name = "启动标识，0关闭，1启动，用于标识该场景是否可被触发执行")
    @EnumCheck(enableClass = FlagOneZeroEnum.class, message = "activeFlag为错误的枚举值", groups = {Add.class, Update.class, Model.class})
    private String activeFlag;

    /**
     * 该场景下条件间关系类型，1 串联-且 ，0 并联-或
     */
    @NotBlank(message = "relationType不能为空", groups = {Add.class})
    @EnumCheck(enableClass = FlagOneZeroEnum.class, message = "relationType为错误的枚举值", groups = {Add.class, Update.class, Model.class})
    private String relationType;

    /**
     * 执行类型，1 手动触发 0 自动（定时或设备触发等）
     */
    @NotBlank(message = "execType不能为空", groups = {Add.class})
    @EnumCheck(enableClass = FlagOneZeroEnum.class, message = "execType为错误的枚举", groups = {Add.class, Update.class, Model.class})
    private String execType;

    /**
     * 来源，添加即从哪个场景模板的id添加过来的
     */
    private Long derive;

    /**
     * 点赞/收藏 数量
     */
    @Excel(name = "点赞/收藏 数量")
    private Long tags;

    /**
     * 是否为模板，1是0否，
     * 标识该场景是否提供给其他人查看
     * 用户可自己设置是否为模板，运营人员添加模板等，查询模板需屏蔽具体设备号
     */
    @EnumCheck(enableClass = FlagOneZeroEnum.class, message = "isModel为错误的枚举值", groups = {Add.class, Update.class, Model.class})
    private String isModel;

    public interface Add {
        //校验分组，添加
    }

    public interface Update {
        //校验分组，更新
    }

    public interface Model {
        //设置模板
    }

    /**
     * 获取关系类型描述
     *
     * @return
     */
    public String getRelationTypeDesc() {
        if (this.getRelationType().equals("1")) {
            return "且";
        }
        if (this.getRelationType().equals("0")) {
            return "或";
        }
        return StringUtils.EMPTY;
    }

}
